package com.rock.code.report.resource.controller;

import com.rock.code.base.controller.BaseController;
import com.rock.code.report.resource.service.JbResourceReportService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 资源视图
 *
 * @author  zhaowei
 * @date 2018/05/12
 */

@Controller
@RequestMapping("/ResourceReport")
public class JbResourceReportController extends BaseController{

//    List list = new ArrayList();
    @Resource
    private JbResourceReportService jbResourceReportService;

    @RequestMapping("")
    public String resourcePage(){

        return "resource/resourceView";
    }

    /**
     * 资源总览视图表
     * @return
     */
    @RequestMapping(value = "/resourceOvervice" ,method = RequestMethod.POST)
    @ResponseBody
    public Map ResourceOverviewController(){
        List list=new ArrayList();
        HashMap resultMap=new HashMap();
        try{
            list = jbResourceReportService.ResourceOverviewService();
            System.out.println(list.toString());
            List   count = jbResourceReportService.resourceNumService();
            resultMap.put("list",list);
            resultMap.put("count",count);
        }catch (Exception e){
            e.printStackTrace();
        }
        return resultMap;
    }

    /**
     * 查询视图总览中的数量
     * @return
     */
    @RequestMapping("/resourceNum")
    @ResponseBody
    public List resouceNumController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.resourceNumService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 资源使用率
     * @return
     */

    @RequestMapping(value = "/resourceUsageRate", method = RequestMethod.POST)
    @ResponseBody
    public List resourceUsageRateController(){
        List list = new ArrayList();
        try{
            list=jbResourceReportService.resourceUsageRateService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 资源分类使用情况
     * @return
     */
    @RequestMapping(value = "/resourceUseClass",method = RequestMethod.POST )
    @ResponseBody
    public  List resourceUseClassController(){
        List list = new ArrayList();
        try{
            list=jbResourceReportService.resourceUseClassService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 虚拟资源概览表
     * @return
     */
    @RequestMapping(value = "/virtualResourceOvervice", method = RequestMethod.POST)
    @ResponseBody
    public Map virtualResourceOverviceController(){
        List list = new ArrayList();
        HashMap resultMap=new HashMap();
        try{
            list=jbResourceReportService.virtualResourceOverviceService();
            List count = jbResourceReportService.virtualResourceNumService();
            resultMap.put("list",list);
            resultMap.put("count",count);
        }catch (Exception e){
            e.printStackTrace();
        }
        return resultMap;
    }

    /**
     * 虚拟资源概览表数量
     * @return
     */
    @RequestMapping("/virtualResourceNum")
    @ResponseBody
    public List virtualResourceNumController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.virtualResourceNumService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 资源池存储使用概览
     * @return
     */

    @RequestMapping(value = "/resourceStorageOverview", method = RequestMethod.POST)
    @ResponseBody
    public List resourceStorageOverviewController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.resourceStorageOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 资源池CPU使用概览
     * @return
     */
    @RequestMapping(value = "/resourceCpuOverview", method = RequestMethod.POST)
    @ResponseBody
    public List resourceCpuOverviewController(){
        List list = new ArrayList();
        try{
            list=jbResourceReportService.resourceCpuOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 资源池内存使用概览
     * @return
     */

    @RequestMapping(value = "/resourceMemoryOverview", method = RequestMethod.POST)
    @ResponseBody
    public List resourceMemoryOverviewController(){
        List list = new ArrayList();
        try{
            list=jbResourceReportService.resourceMemoryOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 机房概览
     * @return
     */
    @RequestMapping(value = "/machineRoomOverview", method = RequestMethod.POST)
    @ResponseBody
    public List machineRoomOverviewController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.machineRoomOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     *  机房资源视图
     * @return
     */
    @RequestMapping(value = "/machineRoomResourceOverview", method = RequestMethod.POST)
    @ResponseBody
    public List machineRoomResourceOverviewController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.machineRoomResourceOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 机房位置地图展示
     * @return
     */
    @RequestMapping(value = "/machineRoomMapOverview",method = RequestMethod.POST)
    @ResponseBody
    public List machineRoomMapOverviewController(){
        List list = new ArrayList();
        try{
            list = jbResourceReportService.machineRoomMapOverviewService();
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }

}
